package com.ydj.framework.utils.generator;

import com.ydj.framework.exception.CommonException;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 数据库实体类生成
 */
class MainGenerator {


    public static void main(String[] args) throws IOException, CommonException {
        String modelName = "cms";
        String classNames = "DoctorLike, DoctorWorkshopLike, DoctorInstitutionLike";
        String chineseClassNames = "治愈师点赞, 治愈工坊点赞, 机构点赞";


        // 输入输出路径
        File projectDir = GeneratorUtils.findProjectDir();
        System.out.println("项目路径是" + projectDir.getAbsolutePath());
        File templateDir = new File(projectDir, "framework/src/main/resources/javatemplate");
        System.out.println("模板路径是" + templateDir.getAbsolutePath());

        // 这里输入所有的类名，多个类可以用逗号区分
        List<String> classNameList = Arrays.stream(classNames.replace("，", ",").split(","))
                .map(item->item.trim())
                .collect(Collectors.toList());
        List<String> chineseClassNameList = Arrays.stream(chineseClassNames.replace("，", ",").split(","))
                .map(item->item.trim())
                .collect(Collectors.toList());


        // 生成实体类代码
        EntityGenerator.generator(projectDir, templateDir, classNameList, chineseClassNameList);
        // 生成接口和逻辑代码
//        InterfaceGenerator.generator(projectDir, templateDir, modelName, classNameList, chineseClassNameList);
    }
}